/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AddTutee.java
 *
 * Created on Jul 8, 2012, 11:42:51 AM
 */
package monitor;

import java.awt.Color;
import java.awt.Component;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import java.awt.Container;
import java.util.regex.Matcher;

/**
 *
 * @author FrostBiteX77
 */
public class AddTutee extends javax.swing.JFrame {

    String status = "";
    String tutorID = "";
    String selCourse = "";
    String mode = "Add";
    String mode1 = "Tutee";
    private Component frame;
    private Container c;

    /** Creates new form AddTutee */
    public AddTutee() {
        initComponents();
        tutorList.removeAllItems();
        courseList.removeAllItems();
        c = getContentPane();
        c.setBackground(Color.white);

        courseList.addItem("None");
        tutorList.addItem("None");

        QHandler Qhandler = new QHandler();
        DBManager con = new DBManager();
        con.Connect();
        Qhandler.viewCourse();
        con.PullCourse(Qhandler.query, mode1);
        con.Disconnect(con.rs);

        tutorInfo.getColumnModel().getColumn(0).setHeaderValue("ID Number");
        tutorInfo.getColumnModel().getColumn(1).setHeaderValue("Tutor Name");


        refreshTable();



    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        lblID = new javax.swing.JLabel();
        lNameTxt = new javax.swing.JTextField();
        CGPATxt = new javax.swing.JTextField();
        lblCGPA = new javax.swing.JLabel();
        lblName = new javax.swing.JLabel();
        lblTitle = new javax.swing.JLabel();
        mNameTxt = new javax.swing.JTextField();
        lblCourse = new javax.swing.JLabel();
        fNameTxt = new javax.swing.JTextField();
        lblGender = new javax.swing.JLabel();
        pnlGender = new javax.swing.JPanel();
        BtnM = new javax.swing.JRadioButton();
        BtnF = new javax.swing.JRadioButton();
        IDTxt = new javax.swing.JTextField();
        BtnAdd = new javax.swing.JButton();
        BtnClear = new javax.swing.JButton();
        BtnCancel = new javax.swing.JButton();
        lblTutor = new javax.swing.JLabel();
        tutorList = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        tutorInfo = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        eaddTxt = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        contactTxt = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        courseList = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        remarkTxt = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        schedDay = new javax.swing.JComboBox();
        schedTime = new javax.swing.JComboBox();
        degreeBox = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Add Tutee");
        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                formMouseMoved(evt);
            }
        });

        lblID.setText("ID num");

        lNameTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        CGPATxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblCGPA.setText("CGPA");

        lblName.setText("Name");

        lblTitle.setText("TUTEE INFORMATION");

        mNameTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblCourse.setText("Degree Program");

        fNameTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblGender.setText("Gender");

        pnlGender.setBackground(new java.awt.Color(255, 255, 255));

        BtnM.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(BtnM);
        BtnM.setText("Male");

        BtnF.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(BtnF);
        BtnF.setText("Female");

        javax.swing.GroupLayout pnlGenderLayout = new javax.swing.GroupLayout(pnlGender);
        pnlGender.setLayout(pnlGenderLayout);
        pnlGenderLayout.setHorizontalGroup(
            pnlGenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlGenderLayout.createSequentialGroup()
                .addGroup(pnlGenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BtnM)
                    .addComponent(BtnF))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        pnlGenderLayout.setVerticalGroup(
            pnlGenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlGenderLayout.createSequentialGroup()
                .addComponent(BtnM)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BtnF)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        IDTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        BtnAdd.setFont(new java.awt.Font("Modern No. 20", 0, 18));
        BtnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pictures/Add2.png"))); // NOI18N
        BtnAdd.setText("Add");
        BtnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnAddActionPerformed(evt);
            }
        });

        BtnClear.setFont(new java.awt.Font("Modern No. 20", 0, 18));
        BtnClear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pictures/Clear2.png"))); // NOI18N
        BtnClear.setText("Clear All");
        BtnClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnClearActionPerformed(evt);
            }
        });

        BtnCancel.setFont(new java.awt.Font("Modern No. 20", 0, 18));
        BtnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pictures/Cancel.png"))); // NOI18N
        BtnCancel.setText("Cancel");
        BtnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnCancelActionPerformed(evt);
            }
        });

        lblTutor.setText("Tutor");

        tutorList.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None" }));

        tutorInfo.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "ID Number", "Tutor Name"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tutorInfo.setGridColor(new java.awt.Color(204, 255, 204));
        jScrollPane1.setViewportView(tutorInfo);
        tutorInfo.getColumnModel().getColumn(0).setResizable(false);

        jLabel1.setText("Schedule");

        jLabel2.setText("Email Address");

        eaddTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 13));
        jLabel4.setText("CHOOSE YOUR TUTOR");

        jLabel3.setText("Contact Number");

        contactTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        contactTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                contactTxtActionPerformed(evt);
            }
        });

        jLabel5.setText("Course (PTS)");

        courseList.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None" }));

        jLabel6.setText("Remarks");

        remarkTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel11.setText("First Name");

        jLabel12.setText("Middle Name");

        jLabel13.setText("Last Name");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel7.setText("*SELECT COURSE FIRST BEFORE SELECTING TUTOR*");

        schedDay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-list of sched days-", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }));

        schedTime.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-list of sched time-", "0800-0930", "0940-1110", "1120-1250", "1300-1430", "1440-1610", "1620-1750" }));

        degreeBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-your degree program-", "CS-CSE", "CS-NE", "CS-ST", "INSYS", "CS-IST" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblTitle)
                        .addGap(459, 459, 459))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(4, 4, 4)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(lblCGPA)
                                            .addComponent(lblCourse)
                                            .addComponent(jLabel6)
                                            .addComponent(lblID)
                                            .addComponent(lblName))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(CGPATxt)
                                                    .addComponent(IDTxt)
                                                    .addComponent(fNameTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                                                    .addGroup(layout.createSequentialGroup()
                                                        .addGap(10, 10, 10)
                                                        .addComponent(jLabel11))
                                                    .addComponent(degreeBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                                .addGap(6, 6, 6)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addGroup(layout.createSequentialGroup()
                                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(jLabel2)
                                                            .addComponent(jLabel3))
                                                        .addGap(18, 18, 18)
                                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(eaddTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                                                            .addComponent(contactTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)))
                                                    .addGroup(layout.createSequentialGroup()
                                                        .addGap(1, 1, 1)
                                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addGroup(layout.createSequentialGroup()
                                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                                    .addGroup(layout.createSequentialGroup()
                                                                        .addComponent(lblGender, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                        .addComponent(pnlGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                    .addGroup(layout.createSequentialGroup()
                                                                        .addGap(10, 10, 10)
                                                                        .addComponent(jLabel12)))
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jLabel13))
                                                            .addGroup(layout.createSequentialGroup()
                                                                .addComponent(mNameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(lNameTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE))))))
                                            .addComponent(remarkTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 557, Short.MAX_VALUE)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(lblTutor, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(20, 20, 20)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(schedDay, 0, 172, Short.MAX_VALUE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(schedTime, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(tutorList, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel7)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabel5)
                                                .addGap(18, 18, 18)
                                                .addComponent(courseList, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(17, 17, 17))))
                            .addComponent(jLabel1))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(BtnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BtnClear)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BtnCancel)
                        .addGap(135, 135, 135))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 660, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(fNameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblName, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(mNameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lNameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(31, 31, 31)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(IDTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblGender, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblID, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(37, 37, 37)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel2)
                                            .addComponent(eaddTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(degreeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(33, 33, 33)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(CGPATxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(contactTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblCGPA)))
                                    .addComponent(pnlGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(remarkTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(12, 12, 12))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addGap(252, 252, 252))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap(71, Short.MAX_VALUE)
                        .addComponent(jLabel12)
                        .addGap(252, 252, 252))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap(71, Short.MAX_VALUE)
                        .addComponent(jLabel11)
                        .addGap(252, 252, 252)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTutor, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tutorList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(schedDay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(schedTime, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(courseList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnClear, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void BtnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnCancelActionPerformed
// TODO add your handling code here:
    AddOptions add = new AddOptions();
    add.setVisible(true);
    add.setLocationRelativeTo(null);
    this.dispose();

}//GEN-LAST:event_BtnCancelActionPerformed

    public void setTutorId(String tutorId) {

        tutorID = tutorId;
    }

private void BtnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnAddActionPerformed
// TODO add your handling code here

    DBManager con1 = new DBManager();
    con1.Connect();
    DBManager con2 = new DBManager();
    con2.Connect();
    DBManager con3 = new DBManager();
    con3.Connect();


    char gender;


    if (BtnM.isSelected()) {
        gender = 'M';
    } else if (BtnF.isSelected()) {
        gender = 'F';
    } else {
        gender = '0';
    }


    Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
    Matcher m = p.matcher(eaddTxt.getText());
    boolean matchFound = m.matches();



    if ((IDTxt.getText().equals(""))
            || (fNameTxt.getText().equals(""))
            || (lNameTxt.getText().equals(""))
            || (gender == '0')
            || (tutorList.getSelectedItem().equals("None"))
            || (eaddTxt.getText().equals(""))
            || (contactTxt.getText().equals(""))
            || (CGPATxt.getText().equals(""))) {

        JOptionPane.showMessageDialog(frame,
                "Please Complete all Fields.",
                "Incomplete",
                JOptionPane.WARNING_MESSAGE);
    } else if (!(Pattern.matches("([a-zA-Z]+\\s+)*[a-zA-Z]+", fNameTxt.getText()))
            || !(Pattern.matches("([a-zA-Z]+\\s+)*[a-zA-Z]+", lNameTxt.getText()))) {

        JOptionPane.showMessageDialog(frame,
                "Tutee name should only contain valid characters.",
                "Invalid",
                JOptionPane.WARNING_MESSAGE);
    } else if (schedDay.getSelectedItem().toString().equals("-list of sched days-") || schedTime.getSelectedItem().toString().equals("-list of sched time-")) {
        JOptionPane.showMessageDialog(frame,
                "Please select your desired schedule.",
                "Incomplete",
                JOptionPane.WARNING_MESSAGE);
    } else if (degreeBox.getSelectedItem().toString().equals("-your degree program-")) {
        JOptionPane.showMessageDialog(frame,
                "Please select your degree program.",
                "Incomplete",
                JOptionPane.WARNING_MESSAGE);
    } else if (Float.parseFloat(CGPATxt.getText()) < 0 || Float.parseFloat(CGPATxt.getText()) > 4) {
        JOptionPane.showMessageDialog(frame,
                "Make sure CGPA is between 0.0 and 4.0.",
                "Invalid",
                JOptionPane.WARNING_MESSAGE);
    } else if (IDTxt.getText().length() != 8) {
        JOptionPane.showMessageDialog(frame,
                "ID number should be 8 digits.",
                "Invalid",
                JOptionPane.WARNING_MESSAGE);
    } else if (!matchFound) {
        JOptionPane.showMessageDialog(frame,
                "Invalid E-mail Address.",
                "Invalid",
                JOptionPane.WARNING_MESSAGE);
    } else {


        tutorID = tutorList.getSelectedItem().toString();

        status = (String) tutorList.getSelectedItem();

        QHandler Qhandler1 = new QHandler();
        QHandler Qhandler2 = new QHandler();
        QHandler Qhandler3 = new QHandler();
        Qhandler1.addTutee(IDTxt.getText(), fNameTxt.getText(), mNameTxt.getText(),
                lNameTxt.getText(), gender, degreeBox.getSelectedItem().toString(), CGPATxt.getText(),
                tutorID, eaddTxt.getText(), remarkTxt.getText());
        Qhandler2.addContactTutee(IDTxt.getText(), contactTxt.getText());
        Qhandler3.addSchedule(tutorID, IDTxt.getText(), schedDay.getSelectedItem().toString(), schedTime.getSelectedItem().toString(), selCourse);

        con1.Push(Qhandler1.query);
        con2.Push(Qhandler2.query);
        con3.Push(Qhandler3.query);
        con1.Disconnect(con1.rs);
        con2.Disconnect(con2.rs);
        con3.Disconnect(con3.rs);




        /*don't remove this*/
        this.setVisible(false);

        AddOptions options = new AddOptions();
        options.setLocationRelativeTo(null);
        options.setVisible(true);

        this.dispose();

    }


}//GEN-LAST:event_BtnAddActionPerformed

private void BtnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnClearActionPerformed
// TODO add your handling code here:
    fNameTxt.setText("");
    mNameTxt.setText("");
    lNameTxt.setText("");
    IDTxt.setText("");
    CGPATxt.setText("");
    eaddTxt.setText("");
    contactTxt.setText("");
    remarkTxt.setText("");
    tutorList.setSelectedIndex(0);
    courseList.setSelectedIndex(0);
    buttonGroup1.clearSelection();
}//GEN-LAST:event_BtnClearActionPerformed

private void contactTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contactTxtActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_contactTxtActionPerformed
    private void refreshTable() {

        selCourse = courseList.getSelectedItem().toString();

        QHandler Qhandler1 = new QHandler();
        DBManager con1 = new DBManager();
        con1.Connect();
        Qhandler1.getTutor(selCourse);
        con1.Pull(Qhandler1.query);
        tutorInfo.setModel(con1.dTableModel);
        con1.Disconnect(con1.rs);

        tutorList.removeAllItems();

        QHandler Qhandler2 = new QHandler();
        DBManager con2 = new DBManager();
        con2.Connect();
        Qhandler2.selectIdNum(selCourse);
        con2.PullInfo(Qhandler2.query, mode);
        con2.Disconnect(con2.rs);

        tutorInfo.getColumnModel().getColumn(0).setHeaderValue("ID Number");
        tutorInfo.getColumnModel().getColumn(1).setHeaderValue("Tutor Name");

        if (tutorList.getSelectedItem() == null) {

            tutorList.addItem("None");
        }



    }
private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved
// TODO add your handling code here:
    refreshTable();
}//GEN-LAST:event_formMouseMoved

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AddTutee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AddTutee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AddTutee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AddTutee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AddTutee().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BtnAdd;
    private javax.swing.JButton BtnCancel;
    private javax.swing.JButton BtnClear;
    private javax.swing.JRadioButton BtnF;
    private javax.swing.JRadioButton BtnM;
    private javax.swing.JTextField CGPATxt;
    private javax.swing.JTextField IDTxt;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextField contactTxt;
    public static javax.swing.JComboBox courseList;
    private javax.swing.JComboBox degreeBox;
    private javax.swing.JTextField eaddTxt;
    private javax.swing.JTextField fNameTxt;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField lNameTxt;
    private javax.swing.JLabel lblCGPA;
    private javax.swing.JLabel lblCourse;
    private javax.swing.JLabel lblGender;
    private javax.swing.JLabel lblID;
    private javax.swing.JLabel lblName;
    private javax.swing.JLabel lblTitle;
    private javax.swing.JLabel lblTutor;
    private javax.swing.JTextField mNameTxt;
    private javax.swing.JPanel pnlGender;
    private javax.swing.JTextField remarkTxt;
    private javax.swing.JComboBox schedDay;
    private javax.swing.JComboBox schedTime;
    private javax.swing.JTable tutorInfo;
    public static javax.swing.JComboBox tutorList;
    // End of variables declaration//GEN-END:variables
}
